package com.itheima.d1_file;

import java.io.File;

public class Test {
    public static void main(String[] args) {
        File dir =new File("D:\\大学");

        File[] files =dir.listFiles();

        for (File file : files) {
            String name = file.getName();
            int indexPos = name.indexOf("二");
            if (indexPos != -1) {
                String index = name.substring(0, indexPos);
                String lastName = name.substring(indexPos);
                String newName = (Integer.valueOf(index) + 1) + lastName;

                file.renameTo(new File(dir, newName));
            }
        }
    }
}
